
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_LOG]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[EBAS_LOG]
GO

CREATE TABLE [dbo].[EBAS_LOG] (
	[GUID] [uniqueidentifier] ROWGUIDCOL NOT NULL ,
	[SIKKERHED_BRUGER_GUID] [uniqueidentifier] NULL ,
	[OPRETTET_DATO] [datetime] NOT NULL ,
	[KILDE_FIL] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL ,
	[KILDE_LINIE] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL ,
	[NIVEAU] [int] NOT NULL ,
	[KATEGORI] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL ,
	[FEJL_TEKST] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL ,
	[BESKRIVELSE] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL 	
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[EBAS_LOG] WITH NOCHECK ADD 
	CONSTRAINT [DF_EBAS_LOG_GUID] DEFAULT (NEWID()) FOR [GUID],
	CONSTRAINT [DF_EBAS_LOG_OPRETTET_DATO] DEFAULT (GetDate()) FOR [OPRETTET_DATO],
	CONSTRAINT [PK_EBAS_LOG] PRIMARY KEY  CLUSTERED 
	(
		[GUID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[EBAS_LOG] ADD 
	CONSTRAINT [FK_EBAS_LOG_EBAS_SIKKERHED_BRUGER] FOREIGN KEY 
	(
		[SIKKERHED_BRUGER_GUID]
	) REFERENCES [dbo].[EBAS_SIKKERHED_BRUGER] (
		[GUID]
	)
GO
